package com.s10.tree;

public class RedBlackTreeTest extends BinarySearchTree {

	public static void main(String[] args) {
		RedBlackTreeTest test = new RedBlackTreeTest();
		test.testDelete();
		test.testInsertLeftRight();
		test.testInsertRightRight();
		test.testInsertRoghtLeft();
		test.testInsertLeftLeft();
	}

	private void testInsertLeftRight() {
		System.out.println("testInsertLeftRight");
		RedBlackTree<Integer> tree = new RedBlackTree<>();
		tree.insert(5);
		tree.insert(2);
		tree.insert(3);
		System.out.println(tree);
	}

	private void testInsertRightRight() {
		System.out.println("testInsertRightRight");
		RedBlackTree<Integer> tree = new RedBlackTree<>();
		tree.insert(2);
		tree.insert(3);
		tree.insert(5);
		System.out.println(tree);
	}

	private void testInsertRoghtLeft() {
		System.out.println("testInsertRoghtLeft");
		RedBlackTree<Integer> tree = new RedBlackTree<>();
		tree.insert(2);
		tree.insert(5);
		tree.insert(3);
		System.out.println(tree);
	}

	private void testInsertLeftLeft() {
		System.out.println("testInsertLeftLeft");
		RedBlackTree<Integer> tree = new RedBlackTree<>();
		tree.insert(5);
		tree.insert(3);
		tree.insert(2);
		System.out.println(tree);
		System.out.println(tree.size());
	}

	private void testDelete() {
		RedBlackTree<Integer> tree = new RedBlackTree<>();
		tree.insert(5);
		tree.insert(3);
		tree.insert(4);
		tree.insert(1);
		tree.insert(7);
		tree.insert(9);
		System.out.println(tree);
		System.out.println(tree.size());

		tree.delete(4);
		System.out.println(tree);

		tree.delete(2);
		System.out.println(tree);

		tree.delete(3);
		System.out.println(tree);

		tree.delete(1);
		System.out.println(tree);
		
		System.out.println(tree.size());
	}

}
